<template>
  <h4>当前x的值:{{x.y}}</h4>
  <button @click="x.y++ ">点x++</button>
  <h1>{{person}}</h1>
  <h2>姓名：{{ name }}</h2>
  <h2>年龄：{{ age }}</h2>
  <h2>薪资：{{ job.j1.salary }}K</h2>
  <button @click="name+='~' ">修改姓名</button>
  <button @click="age++ ">修改年龄</button>
  <button @click="job.j1.salary++ ">涨薪</button>

  <hr>
</template>

<script>
import {ref,toRef, reactive, toRefs,shallowRef,shallowReactive} from 'vue'

export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: 'Demo',

  setup: function () {
    // let person = shallowReactive({ //只考虑第一层数据的响应式
    let person = reactive({
      name: '张三',
      age: 18,
      job: {
        j1: {
          salary: 20
        }
      }
    })
    let x = ref({y:0})
    let y = shallowRef(0)
    console.log(y)

    return {
      person,
      ...toRefs(person),
      x

    }
  }
}
</script>


